﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="UserType.aspx.cs" Inherits="UserType" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function confirm_delete() {
            if (confirm("Are you sure you want to delete") == true)
                return true;
            else
                return false;
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table>
<tr>
    <td>
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
            AllowSorting="True" AllowPaging="True" DataKeyNames="UserTypeId" DataSourceID="SQlUserType"  AutoGenerateDeleteButton="true"  OnRowCreated="GridView1_RowCreated" >
          <Columns>
              
              <asp:CommandField ShowEditButton="True"  ButtonType="Link"   />
              
              <asp:BoundField DataField="UserTypeId" HeaderText="UserTypeId" 
                  InsertVisible="False" ReadOnly="True" SortExpression="UserTypeId" />
              <asp:BoundField DataField="UserType" HeaderText="UserType" 
                  SortExpression="UserType" />
          </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SQlUserType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [tblUserType]" InsertCommand="INSERT INTO [tblUserType] ([UserType]) VALUES (@UserType)" 
            
            UpdateCommand="UPDATE [tblUserType] SET [UserType] = @UserType WHERE UserTypeId = @UserTypeId" 
            DeleteCommand="delete from [tblUserType] WHERE UserTypeId = @UserTypeId">
            <DeleteParameters>
                <asp:Parameter Name="UserTypeId" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="UserType" />
                <asp:Parameter Name="UserTypeId" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="UserType" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
            AutoGenerateRows="False" DataKeyNames="UserTypeId" DefaultMode="Insert"  DataSourceID="SQlUserType">
            <Fields>
                <asp:BoundField DataField="UserTypeId" HeaderText="UserTypeId" 
                    InsertVisible="False" ReadOnly="True" SortExpression="UserTypeId" />
                <asp:BoundField DataField="UserType" HeaderText="UserType" 
                    SortExpression="UserType" />
                <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
         
    </td>
</tr>
</table>
</asp:Content>